﻿@{
    Layout = "_MyLayout";
}
@section styles{
    <link href="~/css/users/changepwd.css" rel="stylesheet" />
}
@section scripts{
    <script type="text/javascript">
        function ChangeMyPassword() {
            debugger;
            var form = $(".changepwd>.form");
            var old = form.find('#oldPassword').val();
            var new1 = form.find('#password1').val();
            var new2 = form.find('#password2').val();

            if (old.length < 1) {
                $("#error_msg").text("原密码不能为空。");
                $(".err-msg").show();
                return;
            }
            if (new1.length < 1) {
                $("#error_msg").text("新密码不能为空。");
                $(".err-msg").show();
                return;
            }
            if (new1.length < 6) {
                $("#error_msg").text("新密码不能少于6位。");
                $(".err-msg").show();
                return;
            }
            if (new1 != new2) {
                $("#error_msg").text("请在密码确认框中输入正确的密码");
                $(".err-msg").show();
                return;
            }

            $.ajax({
                url: '@Url.Content("~/Users/ChangeMyPassword")',
                type: "POST",
                data: {
                    OldPassword: old,
                    New1Password: new1,
                    New2Password: new2
                },
                success: function (re) {
                    if (re.Result) {
                        alert("成功修改密码!");
                    } else {
                        $("#error_msg").text(re.Msg);
                        $(".err-msg").show();
                    }
                },
                error: function (e) {
                    $("#error_msg").text(e.innerText);
                    $(".err-msg").show();
                }
            });
        }
    </script>
}
<div class="changepwd">
    <div class="form">
        <div class="info-title">密码设置</div>
        <div class="row">
            <div class="name">请输入原密码：</div>
            <input type="password" class="pwd-box" placeholder="请输入原密码" id="oldPassword" />
        </div>
        <div class="row">
            <div class="name">请输入密码：</div>
            <input type="password" class="pwd-box" placeholder="请输入新密码(6-16位字母/数字/符号)" id="password1" />
        </div>
        <div class="row">
            <div class="name">请确认密码：</div>
            <input type="password" class="pwd-box" placeholder="请再次确认输入的新密码" id="password2" />
        </div>
        <div class="row" style="height:10px;line-height:10px;">
            <div class="name"></div>
            <div class="err-msg"><i class="fa fa-info-circle"></i><span id="error_msg"></span></div>
        </div>
        <div class="row">
            <div class="name"></div>
            <input type="button" class="submit-btn" value="确 定" onclick="ChangeMyPassword()" />
        </div>
    </div>
</div>